<?php

class ReportController extends Zend_Controller_Action
{
    protected $db;
    
    public function init()
    {
        

        $session = new Zend_Session_Namespace('Zend_Auth_Admin');
        $this->sess = $session->data;

        $this->_helper->layout->setLayout('report');

        if(!isset($this->sess)){
            $param = array(
            'action' => 'admin',
            'controller' => 'index',
            'msg' => 'Session Timeout silahkan login kembali !'
            );
            $this->_redirect($this->view->url($param, 'default', true));
        }

        $this->admin = new Application_Model_Admin();
        
        $this->request = $this->getRequest();
        $this->param = $this->request->getParams();

        $session->action = $this->param['action'];

    }

    public function indexAction()
    {

        //

    }
    

    public function mutasiAction(){

        
        $modelReport = new Application_Model_Report();
        
        $modelFunc = new Application_Model_Functions();
        $this->view->today =  $modelFunc->gatDayIndoName(date('l')).', '.date('d F Y H:i:s');
        

        
        $dateTmp1 = (isset($this->param['date1'])) ? $this->param['date1'] : date('Y-m-d', mktime(0, 0, 0, date("m")  , date("d")-7, date("Y")));
        $dateTmp2 = (isset($this->param['date2'])) ? $this->param['date2'] : date('Y-m-d');

        $date1 = (isset($this->param['date1'])) ? str_replace('-', '', $this->param['date1']) : date('Ymd', mktime(0, 0, 0, date("m")  , date("d")-7, date("Y")));
        $date2 = (isset($this->param['date2'])) ? str_replace('-', '', $this->param['date2']) : date('Ymd');

        $arrDate = array('date1' => $date1, 'date2' => $date2, 'dateTmp1' => $dateTmp1, 'dateTmp2' => $dateTmp2);

        //$this->member = new Application_Model_Member();
        $data = $modelReport->getTotalSaldo();

        $this->view->data = array_merge($data, $arrDate);

        $transTypeList = new Application_Model_TransType();
        $this->view->transTypeList = $transTypeList->transTypeList();
    }

    public function trackingAction(){


        $modelReport = new Application_Model_Report();

        $modelFunc = new Application_Model_Functions();
        $this->view->today =  $modelFunc->gatDayIndoName(date('l')).', '.date('d F Y H:i:s');



        $dateTmp1 = (isset($this->param['date1'])) ? $this->param['date1'] : date('Y-m-d', mktime(0, 0, 0, date("m")  , date("d")-7, date("Y")));
        $dateTmp2 = (isset($this->param['date2'])) ? $this->param['date2'] : date('Y-m-d');

        $date1 = (isset($this->param['date1'])) ? str_replace('-', '', $this->param['date1']) : date('Ymd', mktime(0, 0, 0, date("m")  , date("d")-7, date("Y")));
        $date2 = (isset($this->param['date2'])) ? str_replace('-', '', $this->param['date2']) : date('Ymd');

        $arrDate = array('date1' => $date1, 'date2' => $date2, 'dateTmp1' => $dateTmp1, 'dateTmp2' => $dateTmp2);


        $this->view->data = $arrDate;

        $transTypeList = new Application_Model_TransType();
        $this->view->transTypeList = $transTypeList->transTypeListPPOB();
    }

    public function saldoAction(){

        //

    }
}

